// Playground - noun: a place where people can play

import Cocoa


/*********************************************************************
 * The Swift Language Learning  Chapter 04: Collection Type
 *********************************************************************/


//below two expression are equal
let a1 = Array<String>()
let a2 = String[]()

var shoppingList:String[] = ["egg","milk"]
shoppingList.append("bread") //only string can add to it
shoppingList

shoppingList += ["fruit","water melon"]
shoppingList[0] = "eggs four"
shoppingList


for (index, value) in enumerate(shoppingList) {
	println("Item \(index + 1): \(value)")
}


/*
 *Dictionary
 */
var airports: Dictionary<String, String> = ["TYO": "Tokyo", "DUB": "Dublin"]
airports["BJ"] = "Beijing" //add
airports["TYO"] = "TO"//change
airports

if let oldValue = airports.updateValue("DU", forKey: "DUB") {
	oldValue
}


airports["APL"] = "Apple International"
airports

airports["APL"] = nil //remove APL
airports


for (airportCode, airportName) in airports {
	println("\(airportCode): \(airportName)")
}

for (airportCode) in airports.keys { //keys is not a Array
	println("Airport code: \(airportCode)")
}

let airportCodes = Array(airports.keys)
let airpotrValues = Array(airports.values)

let emptyDictionary = [:]










